A relational database stores data in a number of disparate tables, each of which is linked or related to another table. A table is organized by rows and columns, each row or record containing the same columns or fields. A conventional flat-file database would store all the data in a single table, but the relational model allows for maximum flexibility for querying the data. Data need only be brought together for a particular query, so the structure of the database contains no assumptions about what sort of queries may be required in the future. Another powerful feature of the relational model is that each data item appears only in a single place in the tables and thus only needs to be updated in one place when it changes.
In the relational model, each table has a primary key, which is a field or combination of fields that uniquely identifies each record in the table. The primary key provides a means to distinguish one record from all others in the table.
When a field in one table matches the primary key (or a candidate key) of another table, the field is referred to as a foreign key. The foreign key is the anchor on the many side of a one-to-many or many-to-many relationship, much as the primary or candidate key is the anchor on the one side of this relationship. A foreign key is a linchpin used to ensure that invalid data is not entered into a table. It also prevents a user from deleting or updating in a way that might leave orphan rows.
There are several different classes of relationships possible using a relational model. The first is a one-to-one relationship. Two tables are related in a one-to-one relationship if, for every row in the first table, there is at most one row in a second table. True one-to-one relationships seldom occur in the real world. This type of relationship is often created to get around some limitation of the database management software rather than to model a real-world situation. For example, one-to-one relationships may be necessary in a database when there is a need to split a table into two or more tables because of security or performance concerns. Tables that are related in a one-to-one relationship share the same primary key.
A second type of relationship is a one-to-many relationship. Two tables are related in a one-to-many relationship if, for every row in a first table, there can be zero, one, or many rows in a second table, but for every row in the second table there is exactly one row in the first table. The one-to-many relationship is also referred to as a parent-child or master-detail relationship.
A third type of relationship is a many-to-many relationship. Two tables are related in a many-to-many relationship when, for every row in a first table, there can be many rows in the second table, and for every row in the second table, there can be many rows in the first table. Many-to-many relationships can't be directly modeled in the typical relational database, and therefore these types of relationships must be broken into multiple one-to-many relationships. A third table, known as a linking table, may then be utilized to model the relationships between the two tables.
Regardless of the type of relationship used, past relational models utilized foreign keys for the “many” side of the relationship (except for one-to-one of course). These foreign keys, however, must be constantly managed to ensure that no errors occur in the storage of the data. This wastes both computing power and memory space. Additionally, the traditional heavy-weight dependence on foreign key relationships causes tables to have database enforced key constraints, which limits the ability of a user to easily add new tables or permutations.
What is needed is a solution that eliminates the traditional heavy-weight dependence on foreign key relationships in order to allow users to add new tables or permutations without restrictions.